// @ts-ignore
import CryptoJS from "crypto-js"

// 十六位十六进制数作为密钥
const KEY = CryptoJS.enc.Utf8.parse("1234123412341234")
const encrypt = (str: string) => {
    let encryptedStr = CryptoJS.AES.encrypt(str, KEY, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
    }).toString()
    return encryptedStr
}

const decrypt = (str: string) => {
    let decryptStr = CryptoJS.AES.decrypt(str, KEY, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
    }).toString(CryptoJS.enc.Utf8)
    return decryptStr
}

export {
    encrypt,
    decrypt
}
